﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Aletfa.LightManager.Effects
{
    public sealed class HealingEffect : IGameEffect
    {
        /// <summary>
        /// Numero di punti da curare
        /// </summary>
        public int Number { get; set; }

        /// <summary>
        /// true se devono essere curati anche i danni aggravati
        /// </summary>
        public bool Aggravated { get; set; }

        /// <inheritdoc />
        public string Perform(Unit target)
        {
            int number = this.Number;
            for (int i = target.LifeStatus.Count - 1; i >= 0; i--)
            {
                if (target.LifeStatus[i] == WoundType.Free) continue;
                if (!this.Aggravated)
                    if (target.LifeStatus[i] == WoundType.Aggravated) continue;
                target.LifeStatus[i] = WoundType.Free;
                number--;
                if (number == 0) break;
            }
            return string.Format("{0} recupera {1} punti vita{2}", target.Name, this.Number, (this.Aggravated) ? " (aggravati inclusi)" : "");
        }

        /// <inheritdoc />
        public string Undo(Unit target)
        {
            //anche qua l'undo è amarissimo!
            throw new NotImplementedException();
        }

        /// <inheritdoc />
        public bool IsTemporary
        {
            get { return false; }
        }

        /// <inheritdoc />
        public bool IsOneShot
        {
            get { return false; }
        }
    }
}
